package com.iias.communication.domain;



import com.iias.common.enums.MasterEnum;
import com.iias.communication.consts.CommunicationConst;

import java.io.Serializable;

/**
 * 服务信息
 */
public class ServiceInfo implements Serializable {


    private static final long serialVersionUID = 8613413854485599052L;

    private String ip;

    private Integer port= CommunicationConst.DEFAULT_CLIENT_PORT;

    private MasterEnum masterEnum = MasterEnum.SLAVE;


    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ServiceInfo){
            ServiceInfo serviceInfo  = (ServiceInfo) obj;
            if (serviceInfo.getIp().equals(ip) && port.equals(serviceInfo.getPort()))return true;
        }
        return super.equals(obj);
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public MasterEnum getMasterEnum() {
        return masterEnum;
    }

    public void setMasterEnum(MasterEnum masterEnum) {
        this.masterEnum = masterEnum;
    }


    @Override
    public String toString() {
        return "ServiceInfo{" +
                "ip='" + ip + '\'' +
                ", port=" + port +
                ", masterEnum=" + masterEnum +
                '}';
    }
}
